import requestProxy from '@/utils/request';

const { request } = requestProxy;

// 发票抬头的模糊搜索
export function invoiceTitleSearch(keyword) {
  return request({
    url: '/admin/invoice/title/search',
    method: 'get',
    params: {
      keyword
    }
  });
}

// 发票类型列表
export function getInvoiceTypes(params) {
  return request({
    url: 'admin/invoice/group/types',
    method: 'get',
    params
  });
}

// 获取发票列表
export function getInvoiceList(params) {
  return request({
    url: 'admin/invoice/list',
    method: 'get',
    params
  });
}

// 删除发票
export function delSimInvoice(id) {
  return request({
    url: 'admin/invoice/delete',
    method: 'delete',
    data: {
      ids: [id]
    }
  });
}

// 批量删除发票
export function delBatchInvoice(ids) {
  return request({
    url: 'admin/invoice/delete',
    method: 'delete',
    data: {
      ids
    }
  });
}

// 新建发票
export function createInvoice(data) {
  return request({
    url: 'admin/invoice/create',
    method: 'post',
    data
  });
}

// 编辑发票
export function editInvoice(id, data) {
  return request({
    url: `admin/invoice/edit/${id}`,
    method: 'put',
    data
  });
}

// 发票详情
export function invoiceDetail(id) {
  return request({
    url: `admin/invoice/detail/${id}`,
    method: 'get'
  });
}

// 获取发票关联订单
export function invoiceRelatedOrderIds(data) {
  return request({
    url: 'admin/invoice/relatedOrderIds',
    method: 'post',
    data
  });
}

// 发票管理-获取客户最新信息
export function getClientSingleInfo(id) {
  return request({
    url: `admin/client/singleInfo/${id}`,
    method: 'get'
  });
}

// 发票管理-获取客户最新信息
export function openInvoice(id, data) {
  return request({
    url: `admin/invoice/open/${id}`,
    method: 'put',
    data
  });
}

// 发票管理-获取客户最新信息
export function archInvoice(id) {
  return request({
    url: `admin/invoice/archive/${id}`,
    method: 'put'
  });
}

// 发票管理-开票项目列表
export function getInvoiceProjectList(params) {
  return request({
    url: 'admin/invoice/group/projects',
    method: 'get',
    params
  });
}

// 发票管理-我方抬头列表
export function getOurTitleList(params) {
  return request({
    url: 'admin/invoice/group/ourTitles',
    method: 'get',
    params
  });
}

// 发票管理-tab列表
export function tabList(params) {
  return request({
    url: '/admin/invoice/tab',
    method: 'get',
    params
  });
}

// 不同模块获取我方抬头数据（含历史数据）
export function getModuleOurTitle(type) {
  return request({
    url: `admin/invoice/ourTitle/${type}`,
    method: 'get'
  });
}
// 发票管理-发票号码、发票金额编辑
export function invoiceInfoEdit(id, data) {
  return request({
    url: `admin/invoice/infoEdit/${id}`,
    method: 'put',
    data
  });
}

// 发票列表 - 统计数据
export function getInvoiceStatistics(params) {
  return request({
    url: 'admin/invoice/statistics',
    method: 'get',
    params
  });
}
